package cn.cnsuh.q20_isValid;

import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        System.out.println("isValid(line) = " + isValid(line));
    }
    static boolean isValid(String s) {
        if(s.contains("()")||s.contains("{}")||s.contains("[]")){
            return isValid(s.replace("()", "").replace("[]", "").replace("{}", ""));
        }
        return "".equals(s);
    }
}
